package com.ruoyi.project.system.controller;

import com.ruoyi.framework.aspectj.lang.annotation.Anonymous;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.project.system.service.IQuestionnaireService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * 问卷接口控制器（路径：/system/questionnaire）
 */
@RestController
@RequestMapping("/system/questionnaire")
@Anonymous // 匿名访问（无需登录）
public class QuestionnaireController {

    @Autowired
    private IQuestionnaireService questionnaireService;

    /**
     * 接口：根据二级科室名获取问卷
     * 路径：/system/questionnaire/by-department
     * 参数：department（二级科室名，如"呼吸内科"）
     */
    @GetMapping("/by-department")
    public AjaxResult getQuestionnaireByDept(@RequestParam("department") String department) {
        List<Map<String, Object>> questionnaire = questionnaireService.getQuestionnaireByDept(department);
        return AjaxResult.success(questionnaire);
    }
}